<%--
  Created by IntelliJ IDEA.
  User: de'l'l
  Date: 2021-04-14
  Time: 11:22
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>退货</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js"
            charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
</head>
<body>

<div class="x-body">
    <form class="layui-form">

        <div class="layui-form-item">
            <label for="material" class="layui-form-label">
                <span class="x-red">*</span>食材
            </label>
            <div class="layui-input-inline">

                <select  id="material" name="material"  value="${material}">
                    <option value="0">-请选择-</option>
                    <option value="肉类" <c:if test="${'肉类' eq material}">selected</c:if> >肉类</option>
                    <option value="蔬菜类" <c:if test="${'蔬菜类' eq material}">selected</c:if> >蔬菜类</option>
                    <option value="甜点类" <c:if test="${'甜点类' eq material}">selected</c:if> >甜点类</option>
                    <option value="酒水类" <c:if test="${'酒水类' eq material}">selected</c:if> >酒水类</option>

                </select>
<%--                <input type="text" id="material" name="material"--%>
<%--                       autocomplete="off" class="layui-input">--%>

            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*选择食材</span>
            </div>
        </div>


        <div class="layui-form-item">
            <label for="number" class="layui-form-label">
                <span class="x-red">*</span>数量
            </label>
            <div class="layui-input-inline">
                <input type="text" id="number" name="number"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*退货的数目</span>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button type="button" class="layui-btn" onclick="returnNumber()">
                提交
            </button>
        </div>
    </form>
</div>


<script>
    function returnNumber() {
        var material1 = $("#material").val();
        var number1 = $("#number").val();

        var c = confirm("确定退货吗");
        if (c) {
            $.ajax({
                url: "${pageContext.request.contextPath}/warehouse/returnAjax",
                type: "get",
                data: {"material": material1, "wNumber": number1},
                dataType: "json",

                success: function (data) {
                    if (data.info == "退货成功") {
                        alert("退货成功")
                    } else {
                        alert(data.info)
                    }

                    window.location.href = "${pageContext.request.contextPath}/warehouse/wareHouseReturn";
                    console.log(data.info)
                }
            })
        }

    }


</script>

</body>
</html>
